//
//  AllOrderModel.m
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/12.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "AllOrderModel.h"

@implementation AllOrderModel

+ (AllOrderModel *)parseUserWithDictionary:(NSDictionary *)dict{
    
    AllOrderModel *model = [[AllOrderModel alloc] init];
    
    /**订单时间*/
    model.AddTime = [NSString stringWithFormat:@"%@", dict[@"AddTime"]];
    /**折扣后价格*/
    model.AfterLessPrice = [NSString stringWithFormat:@"%@", dict[@"AfterLessPrice"]];
    /**折扣后全部价格*/
    model.AfterLessTotalPrice = [NSString stringWithFormat:@"%@", dict[@"AfterLessTotalPrice"]];
    /**颜色尺码*/
    if ([[NSString stringWithFormat:@"%@", dict[@"Color"]] isEqualToString:@"(null)"] || [[NSString stringWithFormat:@"%@", dict[@"Color"]] isEqualToString:@""]) {
        model.ColorAndSize = [NSString stringWithFormat:@"%@", dict[@"Size"]];
    }else if ([[NSString stringWithFormat:@"%@", dict[@"Size"]] isEqualToString:@"(null)"] || [[NSString stringWithFormat:@"%@", dict[@"Size"]] isEqualToString:@""]){
        model.ColorAndSize = [NSString stringWithFormat:@"%@", dict[@"Color"]];
    }else{
        model.ColorAndSize = [NSString stringWithFormat:@"%@,%@", dict[@"Color"], dict[@"Size"]];
    }
    /**数量*/
    model.Count = [NSString stringWithFormat:@"%@", dict[@"Count"]];
    /**是否促销*/
    model.IsCuXiao = [NSString stringWithFormat:@"%@", dict[@"IsCuXiao"]];
    /**Id*/
    model.Id = [NSString stringWithFormat:@"%@", dict[@"Id"]];
    /**OrderId*/
    model.OrderId = [NSString stringWithFormat:@"%@", dict[@"OrderId"]];
    /**订单号*/
    model.OrderNO = [NSString stringWithFormat:@"%@", dict[@"OrderNO"]];
    /**图片链接*/
    model.PicPath = [NSString stringWithFormat:@"%@%@", BaseURLStringString,dict[@"PicPath"]];
    /**价格*/
    NSMutableString *countt = [NSMutableString stringWithFormat:@"%@", dict[@"Price"]];
    //查找.
    NSRange rangee = [countt rangeOfString:@"."];
    if (rangee.location == NSNotFound) {
        [countt appendString:@".00"];
    }else if (rangee.length == 1){
        [countt appendString:@"0"];
        countt = [NSMutableString stringWithFormat:@"%.2f", [dict[@"Price"] floatValue]];
    }
    model.Price = [NSString stringWithFormat:@"¥ %@", countt];
    /**ProductCode*/
    model.ProductCode = [NSString stringWithFormat:@"%@", dict[@"ProductCode"]];
    /**ProductId*/
    model.ProductId = [NSString stringWithFormat:@"%@", dict[@"ProductId"]];
    /**商品名*/
    model.ProductName = [NSString stringWithFormat:@"%@", dict[@"ProductName"]];
    /**商品类型*/
    model.ProductType = [NSString stringWithFormat:@"%@", dict[@"ProductType"]];
    /**备注*/
    model.Remark = [NSString stringWithFormat:@"%@", dict[@"Remark"]];
    /**条形码Id*/
    model.SkuId = [NSString stringWithFormat:@"%@", dict[@"SkuId"]];
    /**条形码*/
    model.SkuNO = [NSString stringWithFormat:@"%@", dict[@"SkuNO"]];
    /**总计*/
    NSMutableString *count = [NSMutableString stringWithFormat:@"%@", dict[@"TotalPrice"]];
    //查找.
    NSRange range = [count rangeOfString:@"."];
    if (range.location == NSNotFound) {
        [count appendString:@".00"];
    }else if (range.length == 1){
        [count appendString:@"0"];
        count = [NSMutableString stringWithFormat:@"%.2f", [dict[@"TotalPrice"] floatValue]];
    }
    model.TotalPrice = [NSString stringWithFormat:@"%@", count];
    
    return model;
}

@end
